package client.link.message;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Map;

import client.link.LinkUtil;
import client.link.util.ByteConvert;

import com.google.gson.Gson;

public class SendMessage {
    public static <T> T sendRequest(String json, String ip, int port){
        Socket socket = LinkUtil.getLink(ip, port);
        Gson gson = new Gson();
        try {
            InputStream in = socket.getInputStream();
            
            OutputStream out = socket.getOutputStream();
            byte[] data = json.getBytes("utf-8");
            out.write(ByteConvert.getByteFormInt(data.length));
            out.write(data);
            out.flush();
            
            
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
        
    }
}
